unit u_font;

interface

uses
  System.Drawing,
  Microsoft.DirectX,
  Microsoft.DirectX.Direct3D,
  sysutils;

type

  u_text = Class

  private


    text : Microsoft.DirectX.Direct3D.Font;
    text_to_write : string;
    font1 : System.drawing.font;
    visible : boolean;
    pos_x, pos_y : integer;
    t_color : Color;

  public

    constructor create(dev : Device; taille : integer; couleur : Color; texte : string; t_type : string; fontstyle_ : Fontstyle);
    procedure dispose;
    procedure text_render;
    procedure set_coord(x_, y_ : integer);
    procedure change_text(text : string);
    procedure change_color(color_ : Color);
    function get_text : string;
    procedure set_visible(boule : boolean);

  end;

implementation


  constructor u_text.create(dev : Device; taille : integer; couleur : Color; texte : string; t_type : string; fontstyle_ : Fontstyle);
    begin
      inherited create;
      font1 := System.Drawing.Font.Create(t_type, taille, FontStyle.Regular);
      text := Microsoft.directx.direct3D.font.Create(dev, font1);
      visible := true;
      text_to_write := texte;
      pos_x := 0;
      pos_y := 0;
      t_color := couleur;
    end;

  procedure u_text.dispose;
    begin
      visible := false;
      font1.Free;
      text.Free;
    end;

  procedure u_text.set_coord(x_: Integer; y_: Integer);
    begin
      pos_x := x_;
      pos_y := y_;
    end;

  procedure u_text.change_text(text: string);
    begin
      text_to_write := text;
    end;

  function u_text.get_text : string;
    begin
      Result := text_to_write;
    end;

  procedure u_text.change_color(color_: Color);
    begin
      t_color := color_;
    end;


  procedure u_text.set_visible(boule: Boolean);
    begin
      visible := boule;
    end;

  procedure u_text.text_render;
    begin
    if visible then
      text.DrawText(nil, text_to_write, pos_x, pos_y, t_color);
    end;

end.
